<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MS Office考试系统 - 登录注册</title>
    <style>
        /* 基础重置 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', '微软雅黑', sans-serif;
        }

        :root {
            --office-blue: #2B579A;  /* MS Office主题蓝 */
            --office-orange: #FF8C00;  /* Office主题橙 */
            --deep-gray: #2D2D2D;
            --light-gray: #F5F5F5;
            --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        body {
            background: linear-gradient(135deg, #1E3C72 0%, #2A5298 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        /* 主容器 */
        .auth-container {
            background: rgba(255, 255, 255, 0.95);
            width: 90%;
            max-width: 800px;
            border-radius: 20px;
            box-shadow: 0 12px 24px rgba(0,0,0,0.2);
            display: grid;
            grid-template-columns: 1fr 1fr;
            overflow: hidden;
            position: relative;
        }

        /* 品牌展示区 */
        .brand-section {
            background: var(--office-blue);
            padding: 40px;
            color: white;
            position: relative;
            overflow: hidden;
        }

        .brand-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(45deg, 
                rgba(43, 87, 154, 0.8) 0%, 
                rgba(255, 140, 0, 0.4) 100%);
        }

        .brand-content {
            position: relative;
            z-index: 1;
            height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            text-align: center;
        }

        .office-icon {
            width: 80px;
            height: 80px;
            background: url('./logo_log.png');
            background-repeat: no-repeat;
        }

        /* 表单区 */
        .form-section {
            padding: 50px;
            position: relative;
            transition: var(--transition);
        }

        .form-toggle {
            position: absolute;
            top: 20px;
            right: 20px;
            background: none;
            border: none;
            color: var(--office-blue);
            cursor: pointer;
            font-weight: 600;
        }

        .form-title {
            color: var(--deep-gray);
            margin-bottom: 40px;
            font-size: 24px;
        }

        .form-group {
            margin-bottom: 25px;
            position: relative;
        }

        .form-input {
            width: 100%;
            padding: 12px;
            border: 2px solid #ddd;
            border-radius: 8px;
            font-size: 16px;
            transition: var(--transition);
        }

        .form-input:focus {
            border-color: var(--office-blue);
            outline: none;
            box-shadow: 0 0 8px rgba(43, 87, 154, 0.2);
        }

        .form-button {
            background: var(--office-blue);
            color: white;
            padding: 14px;
            width: 100%;
            border: none;
            border-radius: 8px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: var(--transition);
        }

        .form-button:hover {
            background: #1E3C72;
            transform: translateY(-2px);
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .auth-container {
                grid-template-columns: 1fr;
                margin: 20px;
            }

            .brand-section {
                padding: 30px;
                display: none;
            }

            .form-section {
                padding: 30px;
            }
        }
        .password-strength {
            height: 4px;
            background: #eee;
            margin-top: 8px;
            border-radius: 2px;
        }
        .loading .form-button {
            position: relative;
            color: transparent;
        }
        .loading .form-button::after {
            content: "";
            position: absolute;
            width: 20px;
            height: 20px;
            border: 3px solid #fff;
            border-radius: 50%;
            border-top-color: transparent;
            animation: spin 0.8s linear infinite;
        }
        /* 新增微信登录样式 */
.social-login {
    margin: 1.5rem 0;
    text-align: center;
}

.wechat-login {
    display: inline-flex;
    align-items: center;
    padding: 12px 24px;
    background: #09BB07;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
}

.wechat-login:hover {
    background: #07A405;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(9, 187, 7, 0.3);
}

.wechat-icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
    margin-right: 8px;
}

.divider {
    position: relative;
    margin: 2rem 0;
    text-align: center;
    color: #666;
}

.divider::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    border-top: 1px solid #ddd;
    z-index: 1;
}

.divider span {
    position: relative;
    padding: 0 1rem;
    background: white;
    z-index: 2;
}
/* 保持原有样式不变 */
.social-login {
    margin: 1.5rem 0;
    text-align: center;
}

/* 新增注册表单优化样式 */
#registerSection .form-group {
    margin-bottom: 1.2rem;
}

#registerSection .form-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #eee;
    border-radius: 6px;
    transition: border-color 0.3s;
}

#registerSection .form-input:focus {
    border-color: #2196F3;
    outline: none;
}
    </style>
</head>
<body>
    <div class="auth-container">
        <!-- 品牌展示区保持不变 -->
        <div class="brand-section">
            <div class="brand-overlay"></div>
            <div class="brand-content">
                <div class="office-icon"></div>
                <h2>计算机二级考试系统</h2>
                <p>MS Office 专业备考平台</p>
            </div>
        </div>
    
        <!-- 登录表单（保留微信登录） -->
        <div class="form-section" id="loginSection">
            <button class="form-toggle" onclick="toggleForm()">注册账号 →</button>
            <h2 class="form-title">用户登录</h2>
            
            <!-- 微信登录保留 -->
            <div class="social-login">
                <button class="wechat-login" onclick="wechatLogin()">
                    <svg class="wechat-icon" viewBox="0 0 24 24">
                        <path d="M9.5 4C5.36 4 2 6.69 2 10c0 1.89 1.39 3.57 3.5 4.55V16l3.44-1.88c.47.09.95.13 1.44.13 4.14 0 7.5-2.69 7.5-6s-3.36-6-7.5-6m0 10c-.62 0-1.22-.07-1.79-.2L5.8 14.5 7 12.81C5.19 12.12 4 11.04 4 10c0-2.5 2.46-4.5 5.5-4.5S15 7.5 15 10s-2.46 4.5-5.5 4.5m9.5 1.5c1.11 0 2.11.45 2.83 1.17L22 16v-1.23c0-1.64-1.69-3-3.78-3-1.07 0-2.06.32-2.83.86-.12.08-.25.15-.39.21.28.78.43 1.62.43 2.49 0 .18 0 .35-.03.53.15.03.3.03.45.03z"/>
                    </svg>
                    微信登录
                </button>
            </div>
    
            <div class="divider">
                <span>或</span>
            </div>
    
            <form>
                <div class="form-group">
                    <input type="text" class="form-input" placeholder="用户名/邮箱" required>
                </div>
                <div class="form-group">
                    <input type="password" class="form-input" placeholder="密码" required>
                </div>
                <button type="submit" class="form-button">立即登录</button>
            </form>
        </div>
    
        <!-- 注册表单（移除微信登录） -->
        <div class="form-section" id="registerSection" style="display: none;">
            <button class="form-toggle" onclick="toggleForm()">← 返回登录</button>
            <h2 class="form-title">新用户注册</h2>
    
            <form>
                <div class="form-group">
                    <input type="text" class="form-input" placeholder="用户名" required>
                </div>
                <div class="form-group">
                    <input type="email" class="form-input" placeholder="邮箱" required>
                </div>
                <div class="form-group">
                    <input type="password" class="form-input" placeholder="密码" required>
                </div>
                <div class="form-group">
                    <input type="password" class="form-input" placeholder="确认密码" required>
                </div>
                <button type="submit" class="form-button">立即注册</button>
            </form>
        </div>
    </div>
    

    <script>
        function toggleForm() {
            const login = document.getElementById('loginSection');
            const register = document.getElementById('registerSection');
            login.style.display = login.style.display === 'none' ? 'block' : 'none';
            register.style.display = register.style.display === 'none' ? 'block' : 'none';
        }
        function showError(input, message) {
            const formGroup = input.parentElement;
            formGroup.classList.add('error');
            const error = formGroup.querySelector('.error-message') || document.createElement('div');
            error.className = 'error-message';
            error.textContent = message;
            formGroup.appendChild(error);
        }
        // 微信登录功能
function wechatLogin() {
    // 微信OAuth2.0登录流程
    const appid = 'YOUR_WECHAT_APPID';
    const redirect_uri = encodeURIComponent('YOUR_REDIRECT_URI');
    const state = 'STATE_PARAM'; // 防止CSRF攻击
    const scope = 'snsapi_login'; // 需要用户授权
    
    const authUrl = `https://open.weixin.qq.com/connect/qrconnect?appid=${appid}&redirect_uri=${redirect_uri}&response_type=code&scope=${scope}&state=${state}#wechat_redirect`;
    
    // 打开微信登录窗口
    const loginWindow = window.open(authUrl, '微信登录', 
        'width=500,height=600,top=100,left=100');
    
    // 监听回调
    window.addEventListener('message', (event) => {
        if (event.origin !== 'YOUR_DOMAIN') return;
        
        if (event.data.wechatAuth) {
            const { code, state } = event.data;
            if (state === 'STATE_PARAM') {
                // 发送code到后端获取access_token
                fetch('/api/wechat-login', {
                    method: 'POST',
                    body: JSON.stringify({ code }),
                    headers: {
                        'Content-Type': 'application/json'
                    }
                })
                .then(response => response.json())
                .then(data => {
                    if (data.success) {
                        // 登录成功处理
                        localStorage.setItem('authToken', data.token);
                        window.location.href = '/dashboard';
                    }
                });
            }
        }
    });
}

// 模拟微信回调（开发环境）
function mockWechatCallback() {
    if (window.location.search.includes('mock_wechat=1')) {
        const mockData = {
            code: 'MOCK_CODE_123',
            state: 'STATE_PARAM'
        };
        window.opener.postMessage({ wechatAuth: mockData }, '*');
        window.close();
    }
}

// 优化表单切换动画
function toggleForm() {
    const loginSection = document.getElementById('loginSection');
    const registerSection = document.getElementById('registerSection');
    
    // 添加过渡动画
    loginSection.style.transition = 'opacity 0.3s ease';
    registerSection.style.transition = 'opacity 0.3s ease';
    
    if (loginSection.style.display === 'none') {
        loginSection.style.display = 'block';
        registerSection.style.display = 'none';
    } else {
        loginSection.style.display = 'none';
        registerSection.style.display = 'block';
    }
    
    // 触发重绘保证动画生效
    setTimeout(() => {
        loginSection.style.opacity = loginSection.style.display === 'block' ? 1 : 0;
        registerSection.style.opacity = registerSection.style.display === 'block' ? 1 : 0;
    }, 10);
}
    </script>
</body>
</html>